package cn.niit.smbmsdemo.config;

import cn.niit.smbmsdemo.interceptor.LoginInterceptor;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Controller
public class WebMVCConfig implements WebMvcConfigurer {

    /**
     * 注册拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry){
        InterceptorRegistration registration = registry.addInterceptor((new LoginInterceptor()));
        registration.addPathPatterns("/**");  //拦截所有请求

        /**
         *
         * 设置拦截器白名单：将以下请求排除在拦截目录范围内
         */
    registration.excludePathPatterns("/css/**","/calendar/**","/images/**","/js/**");

   }
}